//
//  FQDRefreshHeader.h
//  FakeQDaily
//
//  Created by mewxiv on 8/21/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import <UIKit/UIKit.h>

UIKIT_EXTERN CGFloat const FQDRefreshPullDownAnimationDuration;
UIKIT_EXTERN CGFloat const FQDRefreshPullBackAnimationDuration;

@class FQDRefreshHeader;
typedef void (^QDRefreshingBlock)(FQDRefreshHeader *header);

@interface FQDRefreshHeader : UIView

// 刷新控件的父级scrollView
@property (nonatomic, weak) UIScrollView *scrollView;
@property (nonatomic, readonly, assign) BOOL isRefreshing;
@property (nonatomic, readonly, assign) CGFloat progress;
// 下拉放开后开始刷新的高度
@property (nonatomic, assign) CGFloat refreshHeight;

+ (instancetype)headerWithRefreshingBlock:(QDRefreshingBlock)refreshingBlock;
+ (instancetype)headerWithTarget:(id)target action:(SEL)action;

// 开始刷新
- (void)beginRefreshing;
// 停止刷新
- (void)endRefreshing;

// 创建子控件
- (void)prepareUI;
// 布局子控件位置和尺寸，子类重写该方法需调用父类方法
- (void)prepareLayoutWithFrame:(CGRect)frame;
// 非刷新状态下根据拖拽进度播放动画
- (void)animateDraggingWithProgress:(CGFloat)progress;
// 即将停止刷新
- (void)willEndRefreshing;
// 已经停止刷新
- (void)didEndRefreshing;
// 即将开始刷新
- (void)willBeginRefreshing;
// 已经开始刷新
- (void)didBeginRefreshing;

@end
